
import  EventEmitter from './EventEmitter';

import  Observer from './Observer';
 
let observable = new EventEmitter();

let [observer1, observer2] = [
    new Observer(1, observable),
    new Observer(2, observable)
]

observer1.on('change', (data) => {
    console.log(`${observer1.id} observered data:`, data);
})

observer2.on('haha', (data) => {
    console.log(`${observer2.id} observered data:`, data);
})

observable.emit('change', { a: 1 }); // 1 observered data: { a: 1 }
observable.emit('haha', [1, 2, 3]); // 2 observered data: [ 1, 2, 3 ]
